/*
 * crearDetalle.java
 *
 * Created on 7 de agosto de 2007, 11:43 AM
 */

package administrador;
import java.sql.*;
import javax.swing.*;
/**
 *
 * @author  daniel1
 */
public class crearDetalle extends javax.swing.JFrame {
 Usuario user;
 Conexion conexion;
 crearAsiento creaAs;
    /** Creates new form AdminCuentas */
    public crearDetalle(Conexion cEnt,Usuario user,crearAsiento caEnt) {
        creaAs=caEnt;
        this.user=user;
        conexion=cEnt;
        initComponents();
        setBounds(200,100,375,214);
        setVisible(true);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        txt_nombre = new javax.swing.JTextField();
        jButton1 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txt_codigo = new javax.swing.JLabel();
        txt_haber = new javax.swing.JTextField();
        txt_parcial = new javax.swing.JTextField();
        txt_debe = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        jPanel1.setLayout(null);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Agregar cuenta"));
        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel2.setText("Cuenta:");
        jPanel1.add(jLabel2);
        jLabel2.setBounds(30, 30, 60, 20);

        jPanel1.add(txt_nombre);
        txt_nombre.setBounds(80, 30, 170, 20);

        jButton1.setText("Buscar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jPanel1.add(jButton1);
        jButton1.setBounds(260, 30, 67, 23);

        jLabel3.setText("Debe:");
        jPanel1.add(jLabel3);
        jLabel3.setBounds(140, 80, 29, 14);

        jLabel4.setText("Haber:");
        jPanel1.add(jLabel4);
        jLabel4.setBounds(240, 80, 33, 14);

        jLabel5.setText("Parcial:");
        jPanel1.add(jLabel5);
        jLabel5.setBounds(30, 80, 50, 14);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel6.setText("Codigo:");
        jPanel1.add(jLabel6);
        jLabel6.setBounds(30, 50, 50, 30);

        txt_codigo.setText("0,0,0");
        jPanel1.add(txt_codigo);
        txt_codigo.setBounds(80, 60, 70, 20);

        jPanel1.add(txt_haber);
        txt_haber.setBounds(240, 100, 90, 20);

        jPanel1.add(txt_parcial);
        txt_parcial.setBounds(30, 100, 100, 20);

        jPanel1.add(txt_debe);
        txt_debe.setBounds(130, 100, 110, 20);

        jButton2.setText("Agregar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jPanel1.add(jButton2);
        jButton2.setBounds(260, 130, 75, 23);

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
        int fila=creaAs.cuentaFilaOcupadas();
        
        creaAs.tabla.setValueAt(this.txt_codigo.getText(),fila,0);
        if(txt_parcial.getText().equals("")&&txt_debe.getText().equals("")){
        creaAs.tabla.setValueAt(this.txt_haber.getText(),fila,3);
        }else if(txt_parcial.getText().equals("")&&txt_haber.getText().equals("")){
        creaAs.tabla.setValueAt(this.txt_debe.getText(),fila,2);
        }else if(txt_haber.getText().equals("")&&txt_debe.getText().equals("")){
        creaAs.tabla.setValueAt(this.txt_parcial.getText(),fila,1);
        }
        this.dispose();
        
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
        BuscadorCuentas bc=new BuscadorCuentas(conexion,this);
    }//GEN-LAST:event_jButton1ActionPerformed
    
   
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    public javax.swing.JLabel txt_codigo;
    private javax.swing.JTextField txt_debe;
    private javax.swing.JTextField txt_haber;
    public javax.swing.JTextField txt_nombre;
    private javax.swing.JTextField txt_parcial;
    // End of variables declaration//GEN-END:variables
    
}
